

import requests
import re
from lxml import etree



url = "https://sh.58.com/ershoufang/pn1/?PGTID=0d30000c-0000-2eb9-e911-5c4d0f03ee9d&ClickID=1"

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
}

response = requests.get(url,headers=headers)
html = response.content.decode('utf-8')
parser = etree.HTML(html)
info = parser.xpath("//ul[@class='house-list-wrap']//li//div[contains(@class,'list-info')]/h2/a")
detail_urls_list = []
for i in info:
    detail_html = etree.tostring(i).decode('utf-8')
    detail_urls = re.findall(r'href="(.*?)" tongji_label',detail_html)
    detail_urls_list.append(''.join(detail_urls))
print(detail_urls_list)